home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / samba / SPEED.txt < prev    next >
Encoding:
Text File  |  1995-04-24  |  8.0 KB  |  234 lines

  1. This file tries to outline the ways to improve the speed of a Samba server.
  2.  
  3. Andrew Tridgell
  4. January 1995
  5.  
  6.  
  7. COMPARISONS
  8. -----------
  9.  
  10. The Samba server uses TCP to talk to the client. Thus if you are
  11. trying to see if it performs well you should really compare it to
  12. programs that use the same protocol. The most readily available
  13. programs for file transfer that use TCP are ftp or another TCP based
  14. SMB server.
  15.  
  16. If you want to test against something like a NT or WfWg server then
  17. you will have to disable all but TCP on either the client or
  18. server. Otherwise you may well be using a totally different protocol
  19. (such as Netbeui) and comparisons may not be valid.
  20.  
  21. Generally you should find that Samba performs similarly to ftp at raw
  22. transfer speed. It should perform quite a bit faster than NFS,
  23. although this very much depends on your system.
  24.  
  25. Several people have done comparisons between Samba and Novell, NFS or
  26. WinNT. In some cases Samba performed the best, in others the worst. I
  27. suspect the biggest factor is not Samba vs some other system but the
  28. hardware and drivers used on the various systems. Given similar
  29. hardware Samba should certainly be competitive in speed with other
  30. systems.
  31.  
  32.  
  33. SOCKET OPTIONS
  34. --------------
  35.  
  36. There are a number of socket options that can greatly affect the
  37. performance of a TCP based server like Samba.
  38.  
  39. The socket options that Samba uses are settable both on the command
  40. line with the -O option, or in the smb.conf file.
  41.  
  42. The "socket options" section of the smb.conf manual page describes how
  43. to set these and gives recommendations.
  44.  
  45. Getting the socket options right can make a big difference to your
  46. performance, but getting them wrong can degrade it by just as
  47. much. The correct settings are very dependent on your local network.
  48.  
  49. The socket option TCP_NODELAY is the one that seems to make the
  50. biggest single difference for most networks. Many people report that
  51. adding "socket options = TCP_NODELAY" doubles the read performance of
  52. a Samba drive. The best explanation I have seen for this is that the
  53. Microsoft TCP/IP stack is slow in sending tcp ACKs.
  54.  
  55.  
  56. READ SIZE
  57. ---------
  58.  
  59. The option "read size" affects the overlap of disk reads/writes with
  60. network reads/writes. If the amount of data being transferred in
  61. several of the SMB commands (currently SMBwrite, SMBwriteX and
  62. SMBreadbraw) is larger than this value then the server begins writing
  63. the data before it has received the whole packet from the network, or
  64. in the case of SMBreadbraw, it begins writing to the network before
  65. all the data has been read from disk.
  66.  
  67. This overlapping works best when the speeds of disk and network access
  68. are similar, having very little effect when the speed of one is much
  69. greater than the other.
  70.  
  71. The default value is 16384, but very little experimentation has been
  72. done yet to determine the optimal value, and it is likely that the best
  73. value will vary greatly between systems anyway. A value over 65536 is
  74. pointless and will cause you to allocate memory unnecessarily.
  75.  
  76.  
  77. MAX XMIT
  78. --------
  79.  
  80. At startup the client and server negotiate a "maximum transmit" size,
  81. which limits the size of nearly all SMB commands. You can set the
  82. maximum size that Samba will negotiate using the "max xmit = " option
  83. in smb.conf.
  84.  
  85. It defaults to 65536 bytes (the maximum), but it is possible that some
  86. clients may perform better with a smaller transmit unit. Trying values
  87. of less than 2048 is likely to cause severe problems.
  88.  
  89. In most cases the default is the best option.
  90.  
  91.  
  92. LOCKING
  93. -------
  94.  
  95. By default Samba does not implement strict locking on each read/write
  96. call (although it did in previous versions). If you enable strict
  97. locking (using "strict locking = yes") then you may find that you
  98. suffer a severe performance hit on some systems.
  99.  
  100. The performance hit will probably be greater on NFS mounted
  101. filesystems, but could be quite high even on local disks.
  102.  
  103.  
  104. LOG LEVEL
  105. ---------
  106.  
  107. If you set the log level (also known as "debug level") higher than 2
  108. then you may suffer a large drop in performance. This is because the
  109. server flushes the log file after each operation, which can be very
  110. expensive. 
  111.  
  112.  
  113. WIDE LINKS
  114. ----------
  115.  
  116. The "wide links" option is now enabled by default, but if you disable
  117. it (for better security) then you may suffer a performance hit in
  118. resolving filenames. The performance loss is lessened if you have
  119. "getwd cache = yes", which is now the default.
  120.  
  121.  
  122. READ RAW
  123. --------
  124.  
  125. The "read raw" operation is designed to be an optimised, low-latency
  126. file read operation. A server may choose to not support it,
  127. however. and Samba makes support for "read raw" optional, with it
  128. being enabled by default.
  129.  
  130. In some cases clients don't handle "read raw" very well and actually
  131. get lower performance using it than they get using the conventional
  132. read operations. 
  133.  
  134. So you might like to try "read raw = no" and see what happens on your
  135. network. It might lower, raise or not affect your performance. Only
  136. testing can really tell.
  137.  
  138.  
  139. WRITE RAW
  140. ---------
  141.  
  142. The "write raw" operation is designed to be an optimised, low-latency
  143. file write operation. A server may choose to not support it,
  144. however. and Samba makes support for "write raw" optional, with it
  145. being disabled by default.
  146.  
  147. It was disabled by default in one of the early Samba versions after
  148. some people reported problems with it. I suspect those problems were
  149. either caused by bugs which have long since been removed or by bugs in
  150. the early Microsoft tcp/ip stacks. If you enable it and strike problem
  151. then please let me know. I will probably enable it again by default in
  152. an upcoming version of Samba.
  153.  
  154.  
  155. READ PREDICTION
  156. ---------------
  157.  
  158. Samba can do read prediction on some of the SMB commands. Read
  159. prediction means that Samba reads some extra data on the last file it
  160. read while waiting for the next SMB command to arrive. It can then
  161. respond more quickly when the next read request arrives.
  162.  
  163. This is disabled by default. You can enable it by using "read
  164. prediction = yes".
  165.  
  166. Note that read prediction is only used on files that were opened read
  167. only.
  168.  
  169. Read prediction should particularly help for those silly clients (such
  170. as "Write" under NT) which do lots of very small reads on a file.
  171.  
  172. Samba will not read ahead more data than the amount specified in the
  173. "read size" option. It always reads ahead on 1k block boundaries.
  174.  
  175.  
  176. MEMORY MAPPING
  177. --------------
  178.  
  179. Samba supports reading files via memory mapping them. One some
  180. machines this can give a large boost to performance, on others it
  181. makes not difference at all, and on some it may reduce performance.
  182.  
  183. To enable you you have to recompile Samba with the -DUSE_MMAP=1 option
  184. on the FLAGS line of the Makefile.
  185.  
  186. Note that memory mapping is only used on files opened read only, and
  187. is not used by the "read raw" operation. Thus you may find memory
  188. mapping is more effective if you disable "read raw" using "read raw =
  189. no".
  190.  
  191.  
  192. SLOW CLIENTS
  193. ------------
  194.  
  195. One person has reported that setting the protocol to COREPLUS rather
  196. than LANMAN2 gave a dramatic speed improvement (from 10k/s to 150k/s).
  197.  
  198. I suspect that his PC's (386sx16 based) were asking for more data than
  199. they could chew. I suspect a similar speed could be had by setting
  200. "read raw = no" and "max xmit = 2048", instead of changing the
  201. protocol. Lowering the "read size" might also help.
  202.  
  203.  
  204. SLOW LOGINS
  205. -----------
  206.  
  207. Slow logins are almost always due to the password checking time. Using
  208. the lowest practical "password level" will improve things a lot. You
  209. could also enable the "UFC crypt" option in the Makefile.
  210.  
  211. CLIENT TUNING
  212. -------------
  213.  
  214. Often a speed problem can be traced to the client. The client (for
  215. example Windows for Workgroups) can often be tuned for better TCP
  216. performance.
  217.  
  218. See your client docs for details. In particular, I have heard rumours
  219. that the WfWg options TCPWINDOWSIZE and TCPSEGMENTSIZE can have a
  220. large impact on performance.
  221.  
  222. Also note that some people have found that setting DefaultRcvWindow in
  223. the [MSTCP] section of the SYSTEM.INI file under WfWg to 3072 gives a
  224. big improvement. I don't know why.
  225.  
  226.  
  227. COMMENTS
  228. --------
  229.  
  230. If you've read this far then please give me some feedback! Which of
  231. the above suggestions worked for you?
  232.  
  233. Mail the samba mailing list or Andrew.Tridgell@anu.edu.au
  234.